//
//  JWMovieDetailPictureModel.m
//  JWMovie
//
//  Created by Jorn.Wu on 15/7/20.
//  Copyright (c) 2015年 Jorn.Wu. All rights reserved.
//

#import "JWMovieDetailCommentModel.h"
#import "constant.h"

@implementation JWMovieDetailCommentModel

- (instancetype)initWithDictionary:(NSDictionary *)dic{
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dic];
        
        
    }
    return self;
}

+ (instancetype)movieDetailCommentModelWithDictionary:(NSDictionary *)dic{
    return [[self alloc] initWithDictionary:dic];
}

- (void)setOpen:(BOOL)open{
    _open = open;
    
    if ([_delegate respondsToSelector:@selector(openTheCell)]) {
        [_delegate openTheCell];
    }
    
}

- (CGFloat)cellHeight{
    
    // 文字的frame
    
    CGSize maxSizi = CGSizeMake(JWScreenWidth - 60 - 20 * 2 - 10 * 2, 500);     // JWScreenWidth - 60 - JWSpacing * 2 - JWSpacing * 2 ---> label的宽度
    
    CGSize realSize = [self.content boundingRectWithSize:maxSizi
                                                 options:NSStringDrawingUsesLineFragmentOrigin
                                              attributes:@{
                                                           NSFontAttributeName : [UIFont fontWithName:@"黑体-简" size:17]
                                                           }
                                                 context:nil].size;
    
    CGSize newSize = CGSizeMake(JWScreenWidth, realSize.height + 20 + 10 * 2 + 10 * 2);      //20 为昵称的高度，10 前一个为上下间距的高度，后一个为上下外边距的高度
    
    
    if (_open && newSize.height > 85) {//只有一行的话，不用展开
        
        _cellHeight = newSize.height;
        
    }else {
        
        _cellHeight = 85;
    }

    return _cellHeight;
    
}


@end
